import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    // 用户菜单资源信息
    resourceInfo: new Map(),
    tabHeight: 0
  },
  getters: {
    appHeight: state => {
      return (state.tabHeight - 56) + 'px'
    },
    appHeightNum: state => {
      return (state.tabHeight - 56)
    },
    // 获取用户的某个菜单资源信息
    getResourceList: (state) => (menuCode) => {
      return state.resourceInfo.get(menuCode)
    },
    // 获取用户的所有菜单资源信息
    getAllResourceList: (state) => {
      return state.resourceInfo
    },
    // 获取系统当前的语言信息
    getAcceptLanguage: (state) => {
      return state.acceptLanguage
    }
  },
  mutations: {
    /**
         * 设置菜单资源信息
         * @param state
         * @param resources 资源信息
         */
    setResourceInfo (state, resources) {
      if (resources) {
        state.resourceInfo = resources
      }
    },
    setTabHeight (state, height) {
      state.tabHeight = height
    }
  }
})
export default store
